package view.HelperClasses;

import java.awt.Color;
import java.awt.Cursor;
import java.awt.Image;
import java.awt.Insets;
import java.awt.Toolkit;
import java.net.URL;
import javax.swing.ImageIcon;
import javax.swing.JButton;

/**
 *
 * @author Joachim
 */
public class ImageButton extends JButton {
    
    public ImageButton(URL locatie) {
        this("", locatie);
    }
    
    public ImageButton(String text, URL locatie) {
        this.setMargin(new Insets(0, 0, 0, 0));
        this.setBorder(null);
        this.setBorderPainted(false);
        this.setContentAreaFilled(false);
        this.setText(text);
        Image backgroundImage = Toolkit.getDefaultToolkit().getImage(locatie);
        this.setIcon(new ImageIcon(backgroundImage));
        this.setForeground(Color.WHITE);
        this.setHorizontalTextPosition(JButton.CENTER);
        this.setVerticalTextPosition(JButton.CENTER);
        this.setCursor(new Cursor(Cursor.HAND_CURSOR));
    }
    
}
